package com.ems.mapper;

import com.ems.entity.CameraEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ems.vo.CameraVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 摄像头 Mapper 接口
 * </p>
 *
 * @author WuZH
 * @since 2023-11-08
 */
@Mapper
public interface CameraMapper extends BaseMapper<CameraEntity> {

    @Select (value = "<script>SELECT * FROM camera_info ci\n" +
            "<trim prefix=\"WHERE\" prefixOverrides=\"and | or\">" +
            "<if test='cameraVo.stationId!=null'> AND ci.stationId=#{cameraVo.stationId} </if>" +
            "</trim>LIMIT #{cameraVo.page}, #{cameraVo.limit}</script>")
    List<CameraVo> queryList (@Param ("cameraVo") CameraVo cameraVo);

    @Select (value = "<script>SELECT COUNT(1) FROM camera_info ci\n" +
            "<trim prefix=\"WHERE\" prefixOverrides=\"and | or\">" +
            "<if test='cameraVo.stationId!=null'> AND ci.stationId=#{cameraVo.stationId} </if>" +
            "</trim></script>")
    Integer queryCount (@Param ("cameraVo") CameraVo cameraVo);

}
